package org.water.sys.entity;
// Generated 2016-3-4 13:17:55 by Hibernate Tools 3.2.2.GA

import java.util.Date;
import java.util.List;

import javax.persistence.Cacheable;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.water.base.entity.IdEntity;

/**
 * 
 * @author qzy
 *
 */
@Cacheable
@Entity
@Table(name="sys_resource")
public class SysResource extends IdEntity {

	/**
	 * 
	 */
	private static final long serialVersionUID = -3529133869649597012L;
	
	

	public SysResource(String id,String name, SysResource parent) {
		super();
		this.setId(id);
		this.name = name;
		this.parent = parent;
	}
	@Column(name="name")
	private String name;

	/** 
	 * 1-系统（目录）,第一级目录表示系统
	        2-菜单（url地址）
	        3-功能（按钮）.
	 */
	@Column(name="type")
	private Integer type;
	/**
	 * 资源类型名称，根据type来判断 
	 */
	@Transient
	private String typeName;
    
	/**
	 * 父节点
	 */
	@ManyToOne(fetch=FetchType.LAZY)  
	@JoinColumn (name="parent_id")  
	private SysResource parent;
    /**
     * 子资源
     */
	//@OneToMany(cascade=CascadeType.ALL, fetch=FetchType.EAGER, mappedBy="parent")
	@Transient
	private List<SysResource> children;
	 
	/** 
	 * 标识，用于程序内部识别，比如类型为系统时，根据标示显示是否有后台管理界面.
	 */
	@Column(name="identify")
	private String identify;

	/** 
	 * 资源地址.
	 */
	@Column(name="url")
	private String url;

	/** 
	 * 图标地址.
	 */
	@Column(name="img_url")
	private String imgUrl;

	/** 
	 * 图标样式,如果图标地址为空时，使用图标样式.
	 */
	@Column(name="icon")
	private String icon;

	@Column(name="remark")
	private String remark;
	/**
	 * 资源关联接口
	 */
	@Column(name="apis")
	private String apis;
	/** 
	 * 删除状态 0-未删除 1-删除.
	 */
	@Column(name="del_status")
	private Integer delStatus;

	/** 
	 * 创建人.
	 */
	@Column(name="create_user")
	private String createUser;

	/** 
	 * 创建时间.
	 */
	@Column(name="create_date")
	private Date createDate;
	/**
	 * 启用状态 1-启用 0-禁用
	 */
	@Column(name="use_status")
	private Integer useStatus;
	@Transient
	private String useStatusName;
	
	/**
	 * 序号
	 */
	@Column(name="snum")
	private Integer snum;

	public SysResource() {
	}

	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Integer getType() {
		return this.type;
	}

	public void setType(Integer type) {
		this.type = type;
	}

	public SysResource getParent() {
		return this.parent;
	}

	public void setParent(SysResource parent) {
		this.parent = parent;
	}

	public String getIdentify() {
		return this.identify;
	}

	public void setIdentify(String identify) {
		this.identify = identify;
	}

	public String getUrl() {
		return this.url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public String getImgUrl() {
		return this.imgUrl;
	}

	public void setImgUrl(String imgUrl) {
		this.imgUrl = imgUrl;
	}

	public String getIcon() {
		return this.icon;
	}

	public void setIcon(String icon) {
		this.icon = icon;
	}

	public String getRemark() {
		return this.remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	public String getApis() {
		return apis;
	}

	public void setApis(String apis) {
		this.apis = apis;
	}

	public Integer getDelStatus() {
		return this.delStatus;
	}

	public void setDelStatus(Integer delStatus) {
		this.delStatus = delStatus;
	}

	public String getCreateUser() {
		return this.createUser;
	}

	public void setCreateUser(String createUser) {
		this.createUser = createUser;
	}

	public Date getCreateDate() {
		return this.createDate;
	}

	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}

	public Integer getUseStatus() {
		return useStatus;
	}

	public void setUseStatus(Integer useStatus) {
		this.useStatus = useStatus;
	}

	public List<SysResource> getChildren() {
		return children;
	}

	public void setChildren(List<SysResource> children) {
		this.children = children;
	}

	public String getUseStatusName() {
		useStatusName="";
		if(null==useStatus) return "";
        if(1==useStatus)
		{
			useStatusName="启用";
		}
		else if(0==useStatus)
		{
			useStatusName="禁用";
		}
		return useStatusName;
	}

	/** 
	 * 1-系统（目录）,第一级目录表示系统
	 *       2-菜单（url地址）
	 *       3-功能（按钮）.
	 */
	public String getTypeName() {
		typeName="";
		if(null==type) return "";
		if(1==type)
		{
			typeName="目录";
		}
		else if(2==type)
		{
			typeName="菜单";
		}
		else if(3==type)
		{
			typeName="功能";
		}
		return typeName;
	}

	public Integer getSnum() {
		return snum;
	}

	public void setSnum(Integer snum) {
		this.snum = snum;
	}



}
